<!DOCTYPE html>
<html>
<head>
<base href="${basePath}">
<meta charset="UTF-8">
<title>修改区域</title>
$!{include("import_js_css.html")}
<link rel="stylesheet" type="text/css" href="/yueyoga_all2014/app/admin/resources/css/basic.css" />
<script type="text/javascript">
$(function(){
	$('.selectpicker').select2();
});
</script>
</head>
<body>
	$!{include("header.html")}
	<div id="div_container_all">
		<div class="div_search_result clear">
			<div class="panel-heading panel-result-title">
				<h3 class="panel-title">修改</h3>
			</div>
			<!--#var(Area area)-->
			<div id="div_result_task" style="padding:15px;">
				<form class="form-horizontal" action="yueyogaAdmin/editArea.jhtml" method="POST">
					<div class="form-group">
						<label for="inputName" class="col-sm-1 control-label">名　称</label>
						<div class="col-sm-4">
							<input type="text" class="form-control" name="name" id="inputName" value="${area.name}">
						</div>
						<label for="inputSort" class="col-sm-1 control-label">排序</label>
						<div class="col-sm-4">
							<input type="text" class="form-control" name="sort" id="inputSort" value="${area.sort}">
						</div>
						<br /> <br />
						<label for="inputProvince" class="col-sm-1 control-label">所在省</label>
						<div class="col-sm-4">
							<!--#var(Area area,List<Area> provinces, List<Area> citys, List<Area> areas, List<Area> domains)-->
							<select id="inputProvince" data-live-search="true"
								class="selectpicker show-tick" data-width="100%" name="provinceId">
								<option value="">请选择</option>
								<!--#foreach(area in provinces)-->
									<option value="${area.areaId}">${area.name}</option>
								<!-- #end -->
							</select>
						</div>
						
						<label for="inputCity" class="col-sm-1 control-label">所在市</label>
						<div class="col-sm-4">
							<!-- #var(Area provinceArea) -->
							<select id="inputCity" data-live-search="true"
								class="selectpicker show-tick" data-width="100%" name="cityId">
								<option value="">请选择</option>
								<!--#foreach(area in citys)-->
									<option value="${area.areaId}">${area.name}</option>
								<!-- #end -->
							</select>
						</div>
						<br /> <br />
						<label for="inputArea" class="col-sm-1 control-label">所在区</label>
						<div class="col-sm-4">
							<!-- #var(Area cityArea) -->
							<select id="inputArea" data-live-search="true"
								class="selectpicker show-tick" data-width="100%" name="areaId">
								<option value="">请选择</option>
								<!--#foreach(area in areas)-->
									<option value="${area.areaId}">${area.name}</option>
								<!-- #end -->
							</select>
						</div> 
						<label for="inputEnabled" class="col-sm-1 control-label">是否启用</label>
						<div class="col-sm-4">
							<label class="radio-inline">
							<!--#if(area.enable)-->
							<input type="radio" name="enable" value="true" checked="checked">启用
							<!--#else-->
							<input type="radio" name="enable" value="true">启用
							<!--#end-->
							</label>
							<label class="radio-inline">
							<!--#if(!area.enable)-->
							<input type="radio" name="enable" value="false" checked="checked">禁用
							<!--#else-->
							<input type="radio" name="enable" value="false">禁用
							<!--#end-->
							</label>
						</div>
						<br /> <br /> 
						<div class="col-sm-offset-2" style="margin: 10px 155px 0 0; float: right;">
							<button type="submit" class="btn-ade-default">保存</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</body>
</html>
<script type="text/javascript">
	$(function() {
		$("#selTaskType").change(function() {
			var taskType = $(this).val();
			if (taskType == 2) {
				$("#ta_mbr_div").hide();
				$("#ta_gps_div").show();
			} else {
				$("#ta_gps_div").hide();
				$("#ta_mbr_div").show();
			}
		});
		var msg = '${msg}';
		if (msg) {
			alert(msg);
		}
	});
	//省
	$("#inputProvince").change(function() {
		var parentId = $(this).val();
		$.post(
			"yueyogaAdmin/subArea.jhtml",
			{"level": "1", "parentId": parentId},
			function(response) {
				var sub = document.getElementById("inputCity");
				var res = eval("(" + response + ")");
				var id = null;
				var name = null;
				var option = null;
				sub.options.length=0;
				option = new Option("请选择", "");
				sub.options.add(option);
				for(var i=0;i<res.items.length;i++) {
					id = res.items[i].areaId;
					name = res.items[i].name;
					option = new Option(name, id);
					sub.options.add(option);
				}
				var sub1 = document.getElementById("inputArea");
				sub1.options.length=0;
				option = new Option("请选择", "");
				sub1.options.add(option);
			}
		);
	});

	//市
	$("#inputCity").change(function() {
		var parentId = $(this).val();
		$.post(
			"yueyogaAdmin/subArea.jhtml",
			{"level": "2", "parentId": parentId},
			function(response) {
				var sub = document.getElementById("inputArea");
				var res = eval("(" + response + ")");
				var id = null;
				var name = null;
				var option = null;
				sub.options.length=0;
				option = new Option("请选择", "");
				sub.options.add(option);
				for(var i=0;i<res.items.length;i++) {
					id = res.items[i].areaId;
					name = res.items[i].name;
					option = new Option(name, id);
					sub.options.add(option);
				}
			}
		);
	});

	$("#inputProvince").val('${provinceId}');
	$("#inputCity").val('${cityId}');
	$("#inputArea").val('${areaId}');
</script>